package vista;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.StringTokenizer;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;

import javax.swing.JButton;
import javax.swing.JComboBox;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaAgregarJuez extends JFrame {
	private JPanel jPanel1;
	private JLabel lblFechaNacimiento;
	private JTextField txtNombre;
	private JComboBox cmbSexo;
	private JLabel lblSexo;
	private JButton btnAgregarJuez;
	private JTextField txtFecha;
	private JTextField txtApellido;
	private JTextField txtCedula;
	private JLabel lblApellido;
	private JLabel lblNombre;
	private JLabel lblCedula;

	public VentanaAgregarJuez(){
		super("Agregar Juez");
		initGUI();
	}
	
	private void initGUI() {
		try {
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1, BorderLayout.CENTER);
				jPanel1.setLayout(null);
				jPanel1.setPreferredSize(new java.awt.Dimension(323, 218));
				{
					lblCedula = new JLabel();
					jPanel1.add(lblCedula);
					lblCedula.setText("Cedula:");
					lblCedula.setBounds(70, 27, 141, 15);
				}
				{
					lblNombre = new JLabel();
					jPanel1.add(lblNombre);
					lblNombre.setText("Nombre:");
					lblNombre.setBounds(66, 64, 141, 15);
				}
				{
					lblApellido = new JLabel();
					jPanel1.add(lblApellido);
					lblApellido.setText("Apellido:");
					lblApellido.setBounds(65, 100, 141, 15);
				}
				{
					lblFechaNacimiento = new JLabel();
					jPanel1.add(lblFechaNacimiento);
					lblFechaNacimiento.setText("Fecha Nacimiento:");
					lblFechaNacimiento.setBounds(16, 183, 141, 15);
				}
				{
					txtCedula = new JTextField();
					jPanel1.add(txtCedula);
					txtCedula.setBounds(176, 27, 135, 25);
				}
				{
					txtNombre = new JTextField();
					jPanel1.add(txtNombre);
					txtNombre.setBounds(176, 69, 135, 25);
				}
				{
					txtApellido = new JTextField();
					jPanel1.add(txtApellido);
					txtApellido.setBounds(176, 103, 135, 25);
				}
				{
					txtFecha = new JTextField();
					jPanel1.add(txtFecha);
					txtFecha.setBounds(175, 184, 136, 25);
				}
				{
					btnAgregarJuez = new JButton();
					jPanel1.add(btnAgregarJuez);
					btnAgregarJuez.setText("Agregar");
					btnAgregarJuez.setBounds(218, 220, 101, 26);
				}
				{
					lblSexo = new JLabel();
					jPanel1.add(lblSexo);
					lblSexo.setText("Sexo:");
					lblSexo.setBounds(83, 144, 141, 15);
				}
				{
					ComboBoxModel cmbSexoModel = 
							new DefaultComboBoxModel(
									new String[] { "Item One", "Item Two" });
					cmbSexo = new JComboBox();
					jPanel1.add(cmbSexo);
					cmbSexo.setModel(cmbSexoModel);
					cmbSexo.setBounds(177, 145, 134, 25);
				}
			}
			{
				this.setSize(421, 301);
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	
	public String getCedula(){
		return this.txtCedula.getText();
	}
	
	public String getNombre(){
		return this.txtNombre.getText();
	}
	
	public String getApellido(){
		return this.txtApellido.getText();
	}
	
	public Date getFechaNacimiento(){
		String fecha = this.txtFecha.getText();
		
		// convertimos la fecha a Date

		SimpleDateFormat conv= new SimpleDateFormat("dd-MM-yyyy"); 
		java.util.Date d = null;
		try {
			d = conv.parse(fecha);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
		
		Date fechaNacimiento = d;
		
		return fechaNacimiento;
	}
	
	public String getSexo(){
		return this.cmbSexo.getSelectedItem().toString();
	}
	
	public void mostrarMensaje(String mensaje){
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
	
	public void agregarListener(ActionListener accion){
	    this.btnAgregarJuez.addActionListener(accion);
	}
	
	public void limpiarCampos(){
		
		txtCedula.setText("");
		txtNombre.setText("");
		txtApellido.setText("");
		txtFecha.setText("");
		

	}
	
	public void setComboSexo(String [] sexos){
		
		ComboBoxModel cmbTipoFiguraModel = new DefaultComboBoxModel(sexos);
		this.cmbSexo.setModel(cmbTipoFiguraModel);
	}
}
